#!/bin/sh
# startup script for traptodb


JSNMP_HOME=${JSNMP_HOME:-"/usr/local/share/java/jsnmp"}


#-----------------------------------------------------------------------------
# Determine configuration settings
#-----------------------------------------------------------------------------

# Load user-specific log4j configuration
if [ -f "${JSNMP_HOME}/log4j.properties" ]; then 
	DARGS="-Dlog4j.configuration=file:${JSNMP_HOME}/log4j.properties"
fi

#echo ${DARGS}

# Load programm configuration
if [ -f "${JSNMP_HOME}/jsnmp.properties" ]; then 
	DARGS="${DARGS} -Djsnmp.cfg=file:${JSNMP_HOME}/jsnmp.properties"
fi 

#echo ${ARGS}

#-----------------------------------------------------------------------------
# classpath
#-----------------------------------------------------------------------------

LCP=${JSNMP_HOME}/${project.build.finalName}.jar

for l in ${JSNMP_HOME}/lib/*.jar
    do
	LCP="${LCP}:${l}"

done

#-----------------------------------------------------------------------------
# Execute
#-----------------------------------------------------------------------------
case "`uname`" in
     FreeBSD*)
	JAVACMD="${JAVACMD:-"/usr/local/bin/java"}"
	;;
    *) 
	JAVACMD=`which java 2>/dev/null` #this just work on my oracle linux
	;;
esac

if [ ! -x "${JAVACMD}" ]; then
    echo "Error: ${JAVACMD} is not present on your system" >&2
    echo "       Please specify the path to an existing java executable with the" >&2
    echo "       JAVACMD environment variable when running this." >&2
    exit 1
fi
	

#echo "${JAVACMD}" ${DARGS} -classpath "${LCP}" com.crimsec.utils.snmp.traptodb.App ${ARGS} "$@"
                                        
exec "${JAVACMD}" ${DARGS} -classpath "${LCP}" com.crimsec.utils.snmp.traptodb.App ${ARGS} "$@"
